package com.young.springdemo.service.iterator;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@Component
public class testIterator {

//    @PostConstruct
    public void testIterator() {
        List<Object> product = new ArrayList<>();
        product.add("倚天剑");
        product.add("屠龙刀");
        product.add("葵花宝典");
        ProductList productList = new ProductList(product);
        Iterator productIterator = productList.createIterator();
        while (!productIterator.isLast()){
            System.out.println(productIterator.getNextObject());
            productIterator.next();
        }
        System.out.println("====================");
        while (!productIterator.isFirst()){
            System.out.println(productIterator.getPreviousObject());
            productIterator.getPrevious();
        }

    }

}
